package com.briup.es.web.controller;

import com.briup.es.config.response.Result;
import com.briup.es.domain.vo.CategoryVO;
import com.briup.es.service.CategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@Api(tags = "栏目模块")
@RestController
@RequestMapping("/category")
public class CategoryController {

    @Resource
    private CategoryService service;

    @ApiOperation("获取所有一级分类及其子分类信息")
    @GetMapping("/list")
    public Result<List<CategoryVO>> list() {
        // 调用service层方法，处理请求
        List<CategoryVO> list = service.list();
        // 返回请求处理成功的响应
        return Result.success(list)
                .apply("ok");
    }

}


